package fr.ensisa.hassenforder.game.server;

import java.io.InputStream;
import java.util.ArrayList;

import fr.ensisa.hassenforder.network.BasicAbstractReader;
import fr.ensisa.hassenforder.network.Protocol;

public class Reader extends BasicAbstractReader {
	ArrayList params;
	long id;
	String name;

	public Reader(InputStream inputStream) {
		super(inputStream);
	}

	public ArrayList getParams() {
		return params;
	}

	public ArrayList getDisconnect() {
		return params;
	}

	public void receive() {
		type = readInt();
		switch (type) {
		case Protocol.REQU_CONNECT:
			params = new ArrayList();
			params.add(readString());
			params.add(readString());
			break;
		case Protocol.REQU_DISCONNECT:
			params = new ArrayList();
			name = readString();
			// params.add(readString());
			id = readLong();
			// params.add(readLong());
			break;
		case Protocol.REQU_STRATISTIQUE:
			params = new ArrayList();
			params.add(readString());
			params.add(readLong());
			break;
		case Protocol.REQU_ADD_CASH:
			params = new ArrayList();
			params.add(readString());
			params.add(readLong());
			params.add(readInt());
			break;
		case Protocol.REQU_PICTURE:
			params = new ArrayList();
			params.add(readString());
			break;
		case Protocol.REQU_PRODUCTS:
			params = new ArrayList();
			params.add(readString());
			params.add(readLong());
			break;
		case Protocol.REQU_SHOP:
			params = new ArrayList();
			params.add(readString());
			params.add(readLong());
			break;
		case Protocol.REQU_REFRESH:
			params = new ArrayList();
			params.add(readString());
			params.add(readLong());
			break;
		case Protocol.REQU_BUY:
			params = new ArrayList();
			params.add(readString());
			params.add(readLong());
			params.add(readString());
			break;
		case Protocol.REQU_SELL:
			params = new ArrayList();
			params.add(readString());
			params.add(readLong());
			params.add(readString());
			break;
		case Protocol.REQU_CONSUME:
			params = new ArrayList();
			params.add(readString());
			params.add(readLong());
			break;
		case Protocol.REQU_CLEAR:
			params = new ArrayList();
			params.add(readString());
			params.add(readLong());
			break;
			
			
		}
		
	}

}
